package co.za.itweb.securedata;



import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LazyAdapter2 extends BaseAdapter {
    
    private FragmentActivity activity;
    private String[] data;
    private  LayoutInflater inflater=null;
    public  ImageLoader imageLoader; 
    
    public LazyAdapter2(FragmentActivity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return data.length;
    }

    
    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.item, null);

        
        TextView text=(TextView)vi.findViewById(R.id.text);
        text.setTextColor(Color.parseColor(First.LISTTEXTCOLOR));
        TextView summary=(TextView)vi.findViewById(R.id.summary);
        summary.setTextColor(Color.parseColor(First.LISTTEXTCOLOR));
        ImageView image=(ImageView)vi.findViewById(R.id.image);
        imageLoader.DisplayImage(data[position], image);
        summary.setText(Second.summary[position]);
        text.setText(Second.titles[position]);
        return vi;
    }
}